home *** CD-ROM | disk | FTP | other *** search
- Path: cisu2.jsc.nasa.gov!usenet
- From: "James P. Williams" <williams>
- Newsgroups: comp.lang.c++
- Subject: Sorting Algorithm Using Iterators
- Date: 3 Apr 1996 05:50:26 GMT
- Organization: NASA/Johnson Space Center
- Message-ID: <4jt3j2$cbn@cisu2.jsc.nasa.gov>
- NNTP-Posting-Host: lego.jsc.nasa.gov
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 1.1N (X11; I; IRIX 5.2 IP12)
- X-URL: news:comp.lang.c++
-
- Does anyone know of an implementation of Quicksort or Heap Sort that accesses
- the underlying container using iterators only? I have a class hierarchy of
- iterators, each intended to be used with a particular container class. I would
- like to write a single sorting function that can be used on any type of
- container that has an associated iterator class. It would be best if it
- required iteration in only one direction.
-
- The implementations with which I am familiar use array indexing (random access)
- to access the contained items. However, iterators for some classes, e.g.,
- linked lists, are cannot provide random access in constant time, and are more
- appropriate for sequential accesses.
-
- I believe the sorting implementation in the STL accepts only iterators that
- support random access.
-
-
- Thanks,
-
- Jim
-
-